<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>${o.title }</title>
		<jsp:include page="../../../inc/css.jsp"></jsp:include>
		<jsp:include page="../../../inc/js.jsp"></jsp:include>
		<jsp:include page="../../../inc/xheditor.jsp"></jsp:include>
		<script type="text/javascript">
$(function() {
	$("#back").button().click(function() {
		window.history.back();
	});
	$("#close").button().click(function() {
		window.close();
	});
	$('#content').xheditor( {
		upLinkUrl : "upload.do",
		upLinkExt : "zip,rar,txt,doc,docx,xls,ppt",
		upImgUrl : "upload.do",
		upImgExt : "jpg,jpeg,gif,png",
		upFlashUrl : "upload.do",
		upFlashExt : "swf",
		upMediaUrl : "upload.do",
		upMediaExt : "avi",
		onUpload : insertUpload
	});
	$('#content').xheditor( {
		tools : 'full'
	});
	$("#add").button().click(function() {
		$.ajax( {
			type : "POST",
			url : "saveNews.do",
			data : {
				id : $("#id").val(),
				classid : $("#classid").val(),
				title : $("#title").val(),
				content : $("#content").val(),
				attach : $("#attach").val()
			},
			error : function() {
				alert("加载错误");
			},
			success : function(data) {
				alert(data);
			}
		});
	});
});
function insertUpload(data) {
	$("#files").append(
			data + ' <a href="' + data + '" target="_blank">下载</a><br/>');
	$("#attach").val($("#attach").val() + ',' + data);
}
</script>
	</head>
	<body>

		<div style="wdith: 100%; background-color: #ffffff; margin: 0px;">
			<c:if test="${o.classid=='0'}">
				<jsp:include page="../admin/functionPath.jsp">
					<jsp:param value="newsForm.do?id=${o.id}" name="url" />
				</jsp:include>
			</c:if>
			<c:if test="${o.classid>0}">
				<jsp:include page="../admin/functionPath.jsp">
					<jsp:param value="newsForm.do?classid=${o.classid}" name="url" />
				</jsp:include>
			</c:if>
			<form action="saveNews.do" method="post">
				<label>
					标题：
				</label>
				<input type="text" id="title" name="title" style="width: 600px;"
					value="${o.title}">
				<input type="hidden" name="id" id="id" value="${o.id }">
				<input type="hidden" name="classid" id="classid"
					value="${o.classid }">
				<textarea id="content" name="content"
					style="width: 700px; height: 500px;">${o.content }</textarea>
				<br />
				<label>
					附件：
				</label>
				<br />
				<div id="files">
					<c:forEach var="e" items="${attach}">${e.url} <a
							href="${e.url}" target="_blank">下载</a>
						<br />
					</c:forEach>
				</div>
				<input type="hidden" id="attach"
					value="<c:forEach var="e" items="${attach}">${e.url},</c:forEach>">
			</form>
			<center>
				<button id="add">
					发布
				</button>
				<button id="back">
					返回
				</button>
				<button id="close">
					关闭
				</button>
			</center>
		</div>
	</body>
</html>